﻿ <!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Ray Optics Simulation</title>
  <meta property="og:title" content="Ray Optics Simulation">
  <meta property="og:type" content="website">
  <meta property="og:url" content="https://ricktu288.github.io/ray-optics/">
  <meta property="og:image" content="https://ricktu288.github.io/ray-optics/image.png">
  <meta property="og:description" content="An open-source web app to simulate reflection and refraction of light.">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
  <link rel="icon" href="icon128.png" type="image/png">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <script>
    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
    })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

    ga('create', 'UA-82058200-1', 'auto');
    ga('send', 'pageview');
  </script>
  <style>
.carousel-inner > .item > img {
  width: 1280px;
}

.thumbnail.right-caption > img {
  float: left;
  margin-right: 9px;
}

.thumbnail {
  margin-bottom: 5px;
}
.tool-title {
  font-size: 16pt;
  margin-top: 0px;
  margin-bottom: 0px;
}

.mode-title {
  font-size: 16pt;
  margin-top: 0px;
  margin-bottom: 0px;
}

  </style>
</head>
<body>

<div class="container">
  <center>
    <h1><b><span id="title">Ray Optics Simulation</span></b></h1>
    <p id="description">
      An open-source web application to simulate reflection and refraction of light.<br>
      Written in HTML, CSS and JavaScript.
    </p>
    <p>
      <a href="simulator/" target="_blank" class="btn btn-success btn-lg" id="start">Start Application</a>
      <a href="https://github.com/ricktu288/ray-optics" class="btn btn-primary btn-lg" id="github_link">View on GitHub</a>
      <a href="simulator_old/" target="_blank" class="btn btn-info btn-lg" id="start-old">Mobile Version</a>
    </p>
  </center>
  <br>
  <div id="screenshots" class="carousel slide" data-ride="carousel">
    <!-- Indicators -->
    <ol class="carousel-indicators">
      <li data-target="#screenshots" data-slide-to="0" class="active"></li>
      <li data-target="#screenshots" data-slide-to="1"></li>
      <li data-target="#screenshots" data-slide-to="2"></li>
      <li data-target="#screenshots" data-slide-to="3"></li>
      <li data-target="#screenshots" data-slide-to="4"></li>
    </ol>

    <!-- Wrapper for slides -->
    <div class="carousel-inner" role="listbox">
      <div class="item active">
        <img src="img/1.png" alt="1.png">
      </div>
      <div class="item">
        <img src="img/3.png" alt="3.png">
      </div>
      <div class="item">
        <img src="img/2.png" alt="2.png">
      </div>
      <div class="item">
        <img src="img/4.png" alt="4.png">
      </div>
      <div class="item">
        <img src="img/5.png" alt="5.png">
      </div>
    </div>

    <!-- Left and right controls -->
    <a class="left carousel-control" href="#screenshots" role="button" data-slide="prev">
      <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
      <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#screenshots" role="button" data-slide="next">
      <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
      <span class="sr-only">Next</span>
    </a>
  </div>

  <div class="row" style="font-size: 10pt">
    <div class="col-sm-6">
      <div class="col-sm-12">
        <h2 id="tools">Tools</h2>
        <div class="row thumbnail right-caption">
          <img src="img/ray.png" alt="ray" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="ray">Ray</p>
            <span id="ray_desc">
              A single ray of light defined by two points.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/beam.png" alt="Beam" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="beam">Beam</p>
            <span id="beam_desc">
              A parallel beam of rays emerges from a line-segment,
              with density controlled by the "Ray density" slider.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/point_source.png" alt="Point Source" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="point_source">Point Source</p>
            <span id="point_source_desc">
              Rays emerge from a single point,
              with number controlled by the "Ray density" slider.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/mirror.png" alt="Mirror" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="mirror">Mirror</p>
            <span id="mirror_desc">
              Simulate the reflection of light on a mirror.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/mirror_arc.png" alt="Mirror (Arc)" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="mirror_arc">Mirror (Arc)</p>
            <span id="mirror_arc_desc">
              A mirror whose shape is part of a circle,
              which is defined by three points.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/ideal_curved_mirror.png" alt="Ideal curved mirror" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="ideal_curved_mirror">Ideal curved mirror</p>
            <span id="ideal_curved_mirror_desc">
              The idealized "curved" mirror which obeys exactly the mirror equation (1/p + 1/q = 1/f).
              The focal length (in pixels) can be set directly.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/glass_halfplane.png" alt="Glass" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="glass_halfplane">Glass</p>
            <span id="glass_halfplane_desc">
              Simulate the the refraction and reflection of light on a surface.
              The intensities are calculated by assuming unpolarized.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/glass_circle.png" alt="Glass (Circle)"  class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="glass_circle">Glass (Circle)</p>
            <span id="glass_circle_desc">
              Glass with circle shape, defind by its center and a point on the surface.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/glass.png" alt="Glass (Other shapes)"  class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="glass">Glass (Other shapes)</p>
            <span id="glass_desc">
              Glass with any shapes constructed from line segments and circular arcs,
              including prisms and "spherical" lenses.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/ideal_lens.png" alt="Glass (Ideal lens)"  class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="ideal_lens">Glass (Ideal lens)</p>
            <span id="ideal_lens_desc">
              An ideal lens which obeys exactly the thin lens equation (1/p + 1/q = 1/f).
              The focal length (in pixels) can be set directly.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/blocker.png" alt="Blocker" class="img-rounded">
          <div class="caption">
            <p class="tool-title" id="blocker">Blocker</p>
            <span id="blocker_desc">
              A line-segment light blocker which absorbes the incident rays.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/ruler.png" alt="Ruler"  style="width:100px;" class="img-rounded">
          <div class="caption" class="img-rounded">
            <p class="tool-title" id="ruler">Ruler</p>
            <span id="ruler_desc">
              A ruler from a point for zero and another point.
              The scale is in pixels.
            </span>
          </div>
        </div>
        <div class="row thumbnail right-caption">
          <img src="img/protractor.png" alt="Protractor" style="width:100px;" class="img-rounded">
          <div class="caption" class="img-rounded">
            <p class="tool-title" id="protractor">Protractor</p>
            <span id="protractor_desc">
              A protractor defined from center and another point for the zero direction.
              The scale is in degrees.
            </span>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-6">
      <div class="col-sm-12">
        <h2 id="views">Views</h2>
        <div class="row thumbnail">
          <div class="caption">
            <p class="mode-title" id="rays">Rays</p>
            <span id="rays_desc">
              Show the rays. When the "Ray density" is high, they appears to be continuous.
            </span>
          </div>
          <img src="img/low_density.png" alt="Low density" class="img-rounded">
          <img src="img/high_density.png" alt="High density" style="margin-top:5px" class="img-rounded">
        </div>
        <div class="row thumbnail">
          <div class="caption">
            <p class="mode-title" id="extended_rays">Extended Rays</p>
            <span id="extended_rays_desc">
              Show both the rays and its extension.
              Orange indicates backward extensions, and gray indicates forward ones.
            </span>
          </div>
          <img src="img/extended_rays.png" alt="Extended rays" class="img-rounded">
        </div>
        <div class="row thumbnail">
          <div class="caption">
            <p class="mode-title" id="all_images">All Images</p>
            <span id="all_images_desc">
              Show the position of all images.
              Yellow points indicate real images, orange indicate virtual images,
              and gray (none in this picture) indicate virtual objects.
              Note that some images cannot be detected if "Ray density" is not high enough.
            </span>
          </div>
          <img src="img/all_images.png" alt="All images" class="img-rounded">
        </div>
        <div class="row thumbnail">
          <div class="caption">
            <p class="mode-title" id="seen_by_observer">Seen by observer</p>
            <span id="seen_by_observer_desc">
              Simulate the rays and images seen from some position.
              The blue circle is the observer.
              Any rays crossing it are considered to be "observed".
              The observer do not know where the rays actually begin,
              but may think they begin at some point(s) if they intersect there.
              The rays are shown in blue, and the point(s) in orange.
            </span>
          </div>
          <img src="img/seen_by_observer.png" alt="Seen by obeserver" class="img-rounded">
        </div>
      </div>
    </div>
  </div>
  <div style="float: right;">
    <div class="dropup">
      <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
      <span id="language">Language</span>
      <span class="caret"></span></button>
      <ul class="dropdown-menu">
        <li><a href="#" onclick="setLang('en');event.preventDefault();">English</a></li>
        <li><a href="#" onclick="setLang('zh-TW');event.preventDefault();">正體中文</a></li>
        <li><a href="#" onclick="setLang('zh-CN');event.preventDefault();">简体中文</a></li>
      </ul>
    </div>
  </div>
</div>


<script src="locales/en.js"></script>
<script src="locales/zh_CN.js"></script>
<script src="locales/zh_TW.js"></script>

<script>
var default_lang = 'en';
var browser_lang = '';
function setLang(lang) {
  document.body.style.fontFamily = locales[lang].font.message;
  document.title = locales[lang]["page_title"].message;
  if (lang != default_lang) {
    document.getElementById('start').href = 'simulator/?' + lang;
  } else {
    document.getElementById('start').href = 'simulator/';
  }
  if (lang != default_lang) {
    document.getElementById('start-old').href = 'simulator_old/?' + lang;
  } else {
    document.getElementById('start-old').href = 'simulator_old/';
  }
  for (item in locales[lang]) {
    if (document.getElementById(item)) {
      document.getElementById(item).innerHTML = locales[lang][item].message;
    }
  }
}
if (navigator.language) {
  browser_lang = navigator.language;
  if (browser_lang.toLowerCase() == 'zh-tw') {
    default_lang = 'zh-TW';
  }
  if (browser_lang.toLowerCase() == 'zh-cn') {
    default_lang = 'zh-CN';
  }
}

setLang(default_lang);

</script>

</body>
</html>
